package com.colorlight.cloud.complete.entity.po;

import com.colorlight.cloud.complete.entity.enumerate.PowerIndex;
import com.colorlight.cloud.complete.entity.enumerate.PowerStatus;
import com.colorlight.cloud.gateway.api.annotation.name;
import com.colorlight.cloud.gateway.api.message.constraint.basics.object.Trans;
import com.colorlight.iot.proto.complete.entity.CompleteEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PowerInfo implements Trans<PowerInfo, CompleteEntity.PowerInfo> {

    /**
     * 序号
     */
    private PowerIndex index;

    /**
     * 电源状态
     */
    private PowerStatus powerStatus;

    /**
     * 电源1是否正常
     */
    @name("powerNormal")
    private Boolean power1Normal;

    @Override
    public PowerInfo formProto(CompleteEntity.PowerInfo powerInfo) {
        PowerInfo powerInfo1 = Trans.super.formProto(powerInfo);
        // proto框架问题，如果枚举是0的情况下，会丢失
        if(powerInfo1.getIndex() == null){
            powerInfo1.setIndex(PowerIndex.POWER_INDEX_1);
        }
        return powerInfo1;
    }
}

